package com.yaorange.controlller;

import com.yaorange.entity.Association;
import com.yaorange.response.Result;
import com.yaorange.service.AssociationService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 江就
 * @Version 1.0
 * @Date 2025/6/23
 * @Description 协会信息Service实现类
 */
@Slf4j
@RestController
@RequestMapping("/associations")
public class AssociationController {

    @Resource private AssociationService associationService;

    /**
     * 获取单条记录
     * @return
     */
    @GetMapping("/one")
    public Result<?> retrieveOne(){
        Association association= associationService.getOne();
        return Result.success(association);
    }

    /**
     * 根据主键更新协会信息
     */
    @PutMapping("/{id}")
    public Result<?> updateById(@PathVariable Long id, @RequestBody Association association) {
        log.info("修改协会信息：{},{}", id, association);
        association.setId(id);
        associationService.modifyById(association);
        return Result.success();
    }
    
}
